package com.csdj.t309.controller;

import com.csdj.t309.common.WebResult;
import com.csdj.t309.entity.CityArea;
import com.csdj.t309.entity.CityAreaExample;
import com.csdj.t309.entity.DriverSchool;
import com.csdj.t309.entity.DriverSchoolExample;
import com.csdj.t309.service.ICityAreaService;
import com.csdj.t309.service.IDriverSchoolService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class DriverSchoolController {

    @Resource
    private IDriverSchoolService driverSchoolService;

    @GetMapping("open")
    public String open() {
        return "driverinfo";
    }

    @ResponseBody
    @GetMapping("selDriverInfo")
    public WebResult selDriverInfo(@RequestParam(required=true,defaultValue="1") Integer page) {
        PageHelper.startPage(page, 5);
        DriverSchoolExample driverSchoolExample = new DriverSchoolExample();
        List<DriverSchool> list = driverSchoolService.selectByExample(driverSchoolExample);
        PageInfo<DriverSchool> p=new PageInfo<>(list);
        WebResult web = new WebResult();
        if (list != null && list.size() > 0) {
            web.putData("DriverSchool", list);
            web.putData("fy",p);
            return web;
        }
        return null;

    }

}